const DefaultStore = {
    count:1,//数量
    loading:true,//首次加载
    modalVisible: false,//模态场景是否可见
    checkoutmodel:false,//去结账
    transparent: true,//是否透明显示
    categoryArr: [],//所有分类
    topage:0,//选中的tab
    cartArr:[],//购物列表
    detailInfo:{options:[]},//商品的详情
    totalPrice:0.00,
    totalTax:0.00,
    combined:0.00,
    diningtype:'dine-in',
    paytype:'credit-card',
    storeinfo:{//店铺的名称
       
    },
    placeloading:false
}
export const TYPES = {
    ISLOADING: "selfcart/isloading",//第一次加载loding
    APPDATA:"selfcart/getItem",//获取用户信息
    DININGTYPE:"selfcart/diningType",//就餐方式
    GOODSLIST:"selfcart/goodslist",//获取商品list
    ADDCART:"selfcart/Addcart",//添加到购物车
    CARTNUM:"selfcart/CartNum",//数量加购
    SKUSELECTED:"selfcart/skuselected",//加料
    TAPGOODS:"selfcart/Tapgoods",//打开详情
    CHANGEINDEX:"selfcart/Changeindex",//tab点击
    INITPAGE:"selfcart/initpage",//设置tab跳转
    SETMODALVISIBLE:"selfcart/setModalVisible",//隐藏弹窗
    CHANGEPLACEORDERING:"selfcard/changeplaceloading",//修改预付单状态
}
export default  (store = DefaultStore, action) => {
    switch (action.type) {
        case TYPES.ISLOADING:
            return {
                ...store,
                loading:action.loading
            }
        break;
        case TYPES.DININGTYPE:
            return {
                ...store,
                diningtype:action.diningtype
            }
        break;
        case TYPES.APPDATA:
            return {
                ...store,
                storeinfo:action.storeinfo
            }
        break;
        case TYPES.INITPAGE:
            return {
                ...store,
                topage:action.topage
            }
        break;
        case TYPES.SETMODALVISIBLE:
            return {
                ...store,
                count:1,
                [action.name]:action.visible
            }
        break;
        case TYPES.CHANGEINDEX:
            return {
                ...store,
                checkoutmodel:action.checkoutmodel,
                topage:action.topage
            }
        break;
        case TYPES.GOODSLIST:
            return {
                ...store,
                categoryArr:action.categoryArr,//所有类别
                loading:false
            }
        break;
        case TYPES.TAPGOODS:
            return {
                ...store,
                detailInfo:action.detailInfo,
                modalVisible:true,
            }
        break;
        case TYPES.ADDCART:
            return {
                ...store,
                cartArr:action.cartArr,
                totalPrice:action.totalPrice,
                combined:action.combined,
                totalPrice:action.totalPrice,
                totalTax:action.totalTax,
                modalVisible:false,
                count:1
            }
        break;
        case TYPES.CARTNUM:
            return {
                ...store,
                count:action.count
            }
        break;
        case TYPES.SKUSELECTED:
            return {
                ...store,
                detailInfo:action.detailInfo
            }
        break;
        case TYPES.CHANGEPLACEORDERING:
            return {
                ...store,
                placeloading:action.placeloading
            }
        break;
        default:
            return store;
            break;
    }
}